﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BLL;

public partial class CheckoutStep1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["Info"] == null)
            {
                Session["Info"] = new MyShopInfo();
            }
            LoadData();
        }

        if (Session["shop"] == null)
        {
            Response.Redirect("/Default.aspx");
        }
    }

    void LoadData()
    {
        List<ProductShop> listCart = new List<ProductShop>();
        listCart = ((MyShopCart)Session["shop"]).ListProduct;

        DataTable tb = Myfunction.ConvertToDataTable(listCart);
        listProductCart.DataSource = tb;
        listProductCart.DataBind();
    }
    protected void listProductCart_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemIndex >= 0)
        {
            try
            {
                SizeBLL dataSize = new SizeBLL();
                ColourBLL dataColor = new ColourBLL();
                Literal ltSize = (Literal)e.Item.FindControl("ltSize");
                Literal ltColor = (Literal)e.Item.FindControl("ltColor");
                string nameSize = dataSize.GetById(int.Parse(ltSize.Text)).Name;
                string nameColor = dataColor.GetById(int.Parse(ltColor.Text)).Name;
                ltSize.Text = nameSize;
                ltColor.Text = nameColor;
            }
            catch { Exception ex; }

        }
    }
}